package dryd.toolbox;

import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.WindowManager;
import android.widget.RelativeLayout;

import androidx.annotation.Nullable;

import dryd.toolbox.view.RulerView;

/**
 * 文件名:RuleActivity.java
 * 文件功能描述:工具尺实现
 * 开发时间:2020年06月07日
 * 开发单位:多人运动小组
 */

public class RuleActivity extends Activity {
    private  DisplayMetrics dm;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);//保持屏幕不变黑
        setContentView(R.layout.activity_rule);
        //获取屏幕信息
        dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        //获取布局
        RelativeLayout relativeLayout = (RelativeLayout)findViewById(R.id.main_layout);
        //初始化尺子
        RulerView rulerView = new RulerView(this, dm);
        //相对布局中添加尺子布局
        relativeLayout.addView(rulerView);
    }
}
